package logic

import (
	"context"

	"godco/internal/svc"
	"godco/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type CheckSignLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCheckSignLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CheckSignLogic {
	return &CheckSignLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *CheckSignLogic) CheckSign(req *types.CheckSignRequest) (resp *types.CheckSignResp, err error) {
	// todo: add your logic here and delete this line
	_, err = l.svcCtx.UserModel.FindOneByEmail(l.ctx, req.Email)
	if err != nil {
		l.Debugf("UserModel.FindOneByEmail error:", err.Error())
		resp = &types.CheckSignResp{
			Code:       403,
			Message:    err.Error(),
		}
		return resp, nil
	}
	resp = &types.CheckSignResp{
		Code:       0,
		Message:    "success",
	}
	return resp, nil
}
